-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
libstore-c: Add new derivation and store path functions #14555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
64ac27b to
601f966
Compare
601f966 to
58acb5e
Compare
roberth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C API review only
src/libstore-c/nix_api_store.h
Outdated
| nix_c_context * context, | ||
| Store * store, | ||
| const StorePath * path, | ||
| void (*callback)(void * userdata, const nix_derivation * drv), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's propagate the error. I'd say it's more useful for early abort scenarios (multiple calls), but still useful here to use the same error handling mechanism.
| void (*callback)(void * userdata, const nix_derivation * drv), | |
| nix_err (*callback)(nix_c_context * return_ctx, void * userdata, const nix_derivation * drv), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since derivations internally heap allocate, I think I will just make this return a pointer to a derivation on the heap too.
91bb0a1 to
20347d7
Compare
|
OK I moved some of the new stuff in to https://github.com/NixOS/nix/tree/more-store-ffi-2 so this is smaller in scope. |
20347d7 to
a568edd
Compare
These do a read/write test in the middles of some computation. They are an imperative way to test intermediate values rather than functionally testing end outputs.
`nix derivation add`, and its C API counterpart, now works a bit closer to `builtins.derivation` in that they don't require the user to fill-in input addressed paths correctly ahead of time. The logic for this is carefully deduplicated, between all 3 entry points, and also between the existing `checkInvariants` function. There are some more functional tests, and there are also many more unit tests. Co-authored-by: Sergei Zimmerman <[email protected]> Co-authored-by: edef <[email protected]>
Add several new functions to the C API: StorePath operations: - nix_store_path_hash: Extract the hash part from a store path - nix_store_create_from_parts: Construct a store path from hash and name Derivation operations: - nix_derivation_clone: Clone a derivation - nix_derivation_to_json: Serialize a derivation to JSON Store operations: - nix_store_drv_from_store_path: Load a derivation from a store path Test the new functions, and improve documentation of some existing functions to better distinguish them, also. Co-authored-by: Tristan Ross <[email protected]> Co-authored-by: Robert Hensing <[email protected]>
a568edd to
5831567
Compare
Motivation
Trying out new and improved FFI with new and improved bindings + Harmonia.
Context
Rebase of #14031
Depends on #14560
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.